package com.tengju.user.infrastructure.repository.convert;

import com.tengju.user.domain.model.chief.ChiefClub;
import com.tengju.user.domain.model.chief.ChiefId;
import com.tengju.user.domain.model.club.ClubId;
import com.tengju.user.infrastructure.persistence.mybatis.dataobject.ChiefClubDO;

public class ChiefClubConvert {

    public static ChiefClub convert(ChiefClubDO chiefClubDO) {
        if (chiefClubDO == null) {
            return null;
        }
        return new ChiefClub(
                new ChiefId(chiefClubDO.getChiefId()),
                new ClubId(chiefClubDO.getClubId()),
                chiefClubDO.getCreateBy(),
                chiefClubDO.getUpdateBy()
        );
    }

    public static ChiefClubDO toDo(ChiefClub chiefClub) {
        if (chiefClub == null) {
            return null;
        }
        ChiefClubDO  chiefClubDO = new ChiefClubDO();
        chiefClubDO.setChiefId(chiefClub.getChiefId().getValue());
        chiefClubDO.setClubId(chiefClub.getClubId().getValue());
        chiefClubDO.setCreateBy(chiefClub.getCreateBy());
        chiefClubDO.setUpdateBy(chiefClub.getUpdateBy());
        return chiefClubDO;
    }
}
